<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : XMLTransformation1.xsl
    Created on : 23 novembre 2013, 18:34
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="xml"/>
    
    <xsl:output method="xml" encoding="UTF-8" name="xml"/>

    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:template match="/emploisdutemps">
        
        <xsl:for-each-group select="//cours" group-by="parcours">
        
            <xsl:variable name="p">
                <xsl:value-of select="current-grouping-key()"/>
            </xsl:variable>
            <xsl:result-document format="xml" encoding="UTF-8" href="web\ressources\xml\{$p}.xml">
                <parcours name="{$p}">
                    <xsl:copy-of select="//cours[parcours=$p]"/>
                </parcours>             
            </xsl:result-document>
        </xsl:for-each-group>
    </xsl:template>

</xsl:stylesheet>
